package com.iot.network;

import com.iot.messaage.SendMessage;
import io.vertx.core.http.HttpServerRequest;
import io.vertx.core.http.HttpServerResponse;

/**
 * @author Administrator
 */
public class HttpDeviceSession implements DeviceSession {
    private final HttpServerRequest exchange;

    public HttpDeviceSession(HttpServerRequest exchange) {
        this.exchange = exchange;

    }

    public HttpServerRequest getExchange() {
        return exchange;
    }

    @Override
    public void onClose(Runnable var1) {

    }

    @Override
    public void send(SendMessage reply) {
        HttpServerResponse response = exchange.response();
        // 设置响应头
        response.putHeader("Content-type", "text/html;charset=utf-8");
        // 响应数据
        response.end(reply.getReplyStr());
    }
}
